package com.talent.study.disruptor.height;

import com.lmax.disruptor.EventHandler;
import com.lmax.disruptor.WorkHandler;
import lombok.extern.slf4j.Slf4j;

/**
 * @Author: hszhou
 * @Date: 2025/4/19 11:56
 * @Description:
 * 可以实现EventHandler 也可以实现WorkHandler接口
 */
@Slf4j
public class Handler1 implements EventHandler<Trade> , WorkHandler<Trade> {

    //EventHandler
    @Override
    public void onEvent(Trade event, long sequence, boolean endOfBatch) throws Exception {
        this.onEvent(event);
    }

    //WorkHandler
    @Override
    public void onEvent(Trade event) throws Exception {

        log.info("handler 1");
        event.setName("H1");
        Thread.sleep(1000);
    }
}
